package edu.odu.cs.sstore.client;

import java.util.ArrayList;
import java.util.List;
import java.util.Locale;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.security.core.userdetails.User;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import edu.odu.cs.sstore.dto.DocumentDTO;
import edu.odu.cs.sstore.service.CourseService;
import edu.odu.cs.sstore.service.DocumentService;

@Controller(value="facultyController")
public class FacultyController {
	
	private static final Logger logger = LoggerFactory.getLogger(FacultyController.class);

	@Autowired
	private CourseService courseService;

	@Autowired
	private DocumentService documentService;
	
	@RequestMapping(value="/faculty")
	public ModelAndView faculty(Locale locale, Model model) {
		
		List<DocumentDTO> myDocs = this.documentService.getMyDocuments();
		List<DocumentDTO> sharedDocs = this.documentService.getSharedDocuments();

		
		ModelAndView mav = new ModelAndView("faculty");
		mav.addObject("courses",this.courseService.getCourses());
		mav.addObject("myDocuments",myDocs);
		mav.addObject("sharedDocuments",sharedDocs);
		
		return mav;
	}

}
